// 整理下这道题的思路, 首先需要确定下, 有多少层高,
// 然后才能初始化二叉树, 一旦创建, 每个节点有值, 以及创建时序, 默认是多少?
const readline = require("readline");
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
let initArr = [];
rl.on("line", (line)=>{
if(initArr.length === 0) {
    initArr = JSON.parse(line.trim())
    getResult(initArr)

    // clear
    initArr.length = 0
}
})

class Node {
    constructor(value = null, createIndex = -1) {
        this.value = value
        this.createIndex = createIndex
    }
}

function getResult(initArr) {
    // 获取最大层
    let maxLevel = initArr.reduce((acc, arr)=> Math.max(acc, arr[0]) , 0) + 1
    let n = Math.pow(2, maxLevel + 1) - 1

    let arr = new Array(n).fill(null).map(_ => new Node())
    arr[0].value = -1
    arr[0].createIndex = 0
    for (let i = 0; i < initArr.length; i++) {
        const [level, creteIndex] = initArr[i]
        // 找到父元素, level 确定了index的范围
        let parentIndex = 0
        if(level === 0) {
            parentIndex = 0
        } else {
            let start = Math.pow(2, level) - 1
            let end = Math.pow(2, level + 1) - 2
            for (let j = start; j <= end ; j++) {
                if(arr[j].createIndex === creteIndex) {
                    parentIndex = j
                    break
                }
            }
        }

        // 左元素
        let maxChildCreateIndex = -1
        for (let j = Math.pow(2, level + 1) - 1; j <= Math.pow(2, level + 2) - 2; j++) {
            maxChildCreateIndex = Math.max(arr[j].createIndex, maxChildCreateIndex)
        }

        let leftIndex = 2*parentIndex + 1
        let rightIndex = 2*parentIndex + 2
        if(arr[leftIndex].value === null) {
            arr[leftIndex].value = i
            arr[leftIndex].createIndex = maxChildCreateIndex+1
        } else if(arr[rightIndex].value === null) {
            arr[rightIndex].value = i
            arr[rightIndex].createIndex = maxChildCreateIndex+1
        }
    }
    let ans = []
    arr.forEach((obj, index) => ans.push(obj.value))
    while(ans.at(-1) === null) {
        ans.pop()
    }
    console.log(JSON.stringify(ans).replaceAll(",", ", "))
}
